import json
import random
from random_word import RandomWords


add_cnt = 50

with open('products_origin.json', 'rt') as f:
    data = json.load(f)

r = RandomWords()
total_words = r.get_random_words(limit=add_cnt * 2)
total_cates = ["accessories", 
    "clothing", "tops", "accessories",
    "footwear", "hair", "beauty", "decor", "home", "kitchen"]

for i in range(add_cnt):
    cur_prod = {}
    cur_prod['id'] = hex(random.randint(0, (1 << 40)-1))[2:].upper()
    cur_prod['name'] = ' '.join(total_words[2*i:2*i+2])
    cur_prod['description'] = 'GLULGUGLULGLGLGLUGLUGLUGLUGLULGULGLGUG'
    cur_prod['priceUsd'] = {
        'currencyCode': 'USD',
        'units': random.randint(1, 200),
        'nanos': 990000000
    }
    cur_prod['picture'] = "/static/img/products/hairdryer.jpg"
    cur_prod['categories'] = [random.choice(total_cates)]

    data['products'].append(cur_prod)

with open('products.json', 'wt') as f:
    json.dump(data, f)

with open('../loadgenerator/products.json', 'wt') as f:
    json.dump(data, f)
